<template>
<div class="timeline-block">
  <el-timeline>
    <el-timeline-item placement="top"
    v-for="(diary,did) in diaryList"
    :key="diary.did"
    :timestamp="diary.editTime">

      <el-card>
        <div><h4>更新日记</h4></div>
        <div><p>{{diary.titile}}</p></div>
        <div><p>{{diary.content}}</p></div>
        <el-button @click="gotoWrite">查看全文</el-button>
      </el-card>
      </el-timeline-item>
  </el-timeline>
</div>
</template>

<script>
  import axios from 'axios'
  import Write from './Write.vue'

  export default {
    mounted(){
      var _this = this;
      axios.post('http://abcds.vaiwan.com/show',{

          uid:2,
          state:3

      }).then(function(response){
        console.log(response.data.data);
        _this.diaryList = response.data.data;
      }).catch(function(error){
        console.log(error);
        alert("请求失败！")
      });
    },
    methods:{
      gotoWrite(){
        this.$router.push('/write');
      }
    },
    data(){
      return{
        diaryList:[{
          did:'',
          title:'',
          content:'',
          editTime:''
        }]

        /*实验用数组
        diaryList:[{
          did:'0',
          editTime:'2022-04-12',
          title:'a',
          content:'aa'
        },{
          did:'1',
          editTime:'2022-04-11',
          title:'b',
          content:'aad'
        },{
          did:'2',
          editTime:'2022-04-10',
          title:'av',
          content:'aaaa'
        }]
        */
      }
    }
  }
</script>
